
var param = $.cookie("a"); 
//console.log(param); 

$(function(){
   if(param="order"){
         $(".right-container.zhuye").css("display","block")
         $(".right-container.gerenxinxi").css("display","none")
         $(".right-container.vip_center").css("display","none")
         $(".right-container.shoucang").css("display","none")
         $(".right-container.coupon-container").css("display","none")
         $(".right-container.order").css("display","none")
   }
});


//切换主页面
$(".center").click(function(){
   $(".right-container.zhuye").css("display","block")
   $(".right-container.gerenxinxi").css("display","none")
   $(".right-container.vip_center").css("display","none")
   $(".right-container.shoucang").css("display","none")
   $(".right-container.coupon-container").css("display","none")
   $(".right-container.order").css("display","none")
})

$(".message").click(function(){
   $(".right-container.zhuye").css("display","none")
   $(".right-container.gerenxinxi").css("display","block")
   $(".right-container.vip_center").css("display","none")
   $(".right-container.shoucang").css("display","none")
   $(".right-container.coupon-container").css("display","none")
   $(".right-container.order").css("display","none")
})

$(".vip,.vip-title").click(function(){
   $(".right-container.zhuye").css("display","none")
   $(".right-container.gerenxinxi").css("display","none")
   $(".right-container.vip_center").css("display","block")
   $(".right-container.shoucang").css("display","none")
   $(".right-container.coupon-container").css("display","none")
   $(".right-container.order").css("display","none")
})
$(".my-collection span,.collection").click(function(){
   $(".right-container.zhuye").css("display","none")
   $(".right-container.gerenxinxi").css("display","none")
   $(".right-container.vip_center").css("display","none")
   $(".right-container.shoucang").css("display","block")
   $(".right-container.coupon-container").css("display","none")
   $(".right-container.order").css("display","none")
})
$(".youhuiquan,.discount,.diyongquan").click(function(){
   $(".right-container.zhuye").css("display","none")
   $(".right-container.gerenxinxi").css("display","none")
   $(".right-container.vip_center").css("display","none")
   $(".right-container.shoucang").css("display","none")
   $(".right-container.coupon-container").css("display","block")
   $(".right-container.order").css("display","none")
})

$(".quanbuorder,.order").click(function(){
   $(".right-container.zhuye").css("display","none")
   $(".right-container.gerenxinxi").css("display","none")
   $(".right-container.vip_center").css("display","none")
   $(".right-container.shoucang").css("display","none")
   $(".right-container.coupon-container").css("display","none")
   $(".right-container.order").css("display","block")
})

var liArr = $(".collection-list .list-content").children().length
if(liArr == 0){
   $(".no-col").css("display","block")
}else{
   $(".no-col").css("display","none")
}

var liArr1 = $(".order-list .list-content").children().length
if(liArr == 0){
   $(".no-order").css("display","block")
}else{
   $(".no-order").css("display","none")
}

//切换优惠券状态
document.querySelector(".coupon-ul").onmousedown = function(event){
   var element = event.target; //事件作用的目标元素
   var arr = $(".coupon-ul").children();
   for (let i = 0; i < arr.length; i++) {
      arr[i].className = "coupon_nouse coupon_li";
   }
   console.log(element.parentElement.nodeName)
   if(element.parentElement.nodeName == "SPAN"){
   element.parentElement.parentElement.className = "coupon_nouse coupon_li li_active";
   }else
   element.parentElement.className = "coupon_nouse coupon_li li_active";
}



// ============订单===============
// 筛选订单
document.querySelector("#order-tab").onmousedown = function(event){
   var element = event.target; //事件作用的目标元素
   var arr = $("#order-tab").children();
   // console.log(element.nodeName)
   for (let i = 0; i < arr.length; i++) {
      arr[i].className = "";
   }
   if(element.parentElement.nodeName == "I"){
      element.parentElement.parentElement.className = "focus";
   }else if(element.nodeName == "LI"){
      element.className = "focus";
   }
   else
   element.parentElement.className = "focus";
}

// 根据订单状态筛选
$("#all-order").click(function(){
   // console.log("1111")
   let listarr = $(".order-item-list").children();
   for (let i = 0; i < listarr.length; i++) {
      // listarr.eq(i).css("display","none")
      listarr.eq(i).css("display","block")
   }
})


$("#wait-pay").click(function(){
   let listarr = $(".order-item-list").children();
   console.log(listarr.length)
   for (let i = 0; i < listarr.length; i++) {
      var detail = listarr[i].children;
      var x = detail[1].children;
      var y = x[5].children
      // console.log(y[0].innerText)
      // listarr.eq(i).css("display","none")
      if(y[0].innerText == "待付款"){
      listarr.eq(i).css("display","block")}
      else{ 
      listarr.eq(i).css("display","none")}
   }
})

$("#wait-use").click(function(){
   let listarr = $(".order-item-list").children();
   console.log(listarr.length)
   for (let i = 0; i < listarr.length; i++) {
      var detail = listarr[i].children;
      var x = detail[1].children;
      var y = x[5].children
      // console.log(y[0].innerText)
      // listarr.eq(i).css("display","none")
      if(y[0].innerText == "待使用"){
      listarr.eq(i).css("display","block")}
      else{ 
      listarr.eq(i).css("display","none")}
   }
})

$("#wait-commit").click(function(){
   let listarr = $(".order-item-list").children();
   console.log(listarr.length)
   for (let i = 0; i < listarr.length; i++) {
      var detail = listarr[i].children;
      var x = detail[1].children;
      var y = x[5].children
      // console.log(y[0].innerText)
      // listarr.eq(i).css("display","none")
      if(y[0].innerText == "待评价"){
      listarr.eq(i).css("display","block")}
      else{ 
      listarr.eq(i).css("display","none")}
   }
})

$("#canceled").click(function(){
   let listarr = $(".order-item-list").children();
   console.log(listarr.length)
   for (let i = 0; i < listarr.length; i++) {
      var detail = listarr[i].children;
      var x = detail[1].children;
      var y = x[5].children
      // console.log(y[0].innerText)
      // listarr.eq(i).css("display","none")
      if(y[0].innerText == "已取消"){
      listarr.eq(i).css("display","block")}
      else{ 
      listarr.eq(i).css("display","none")}
   }
})

// let listarr = $(".order-item-list").children();
//    for (let i = 0; i < listarr.length; i++) {
//       var detail = listarr[i].children;
//       var x = detail[1].children;
//       var y = x[5].children
//       if(y[0].innerText == "待付款")
//       waitPayCount++;
//       if(y[0].innerText == "已支付")
//       waitUseCount++;
//       if(y[0].innerText == "待点评")
//       waitCommitCount++;
// 获取各类订单数量
// function titleCount(){
//    var waitPayCount=0
//    var waitUseCount=0
//    var waitCommitCount=0

//    let listarr1 = $("#order-item-box").children;
//    console.log(listarr1)
//    for (let i = 0; i < listarr1.length; i++) {
//       var detail = $("listarr1").eq(i).children;
//       console.log(detail.length)
//       var x = detail[1].children;
//       var y = x[5].children
//       if(y[0].innerText == "待付款")
//       waitPayCount++;
//       if(y[0].innerText == "已支付")
//       waitUseCount++;
//       if(y[0].innerText == "待点评")
//       waitCommitCount++;
//    }
//    console.log("待付款"+ waitPayCount)
//    document.querySelector(".waitPay").innerText = waitPayCount;
//    document.querySelector(".waitUse").innerText = waitUseCount;
//    document.querySelector(".waitCommit").innerText = waitCommitCount;

// }

// titleCount()

// var orderArr=[
//    {
//        hotelName :'苏州尼依格罗酒店', //酒店名称
//        hotelRoomName :'N1豪华大床房', //房间类型
//        personCount : '1', //住房人数
//        checkinDate :'2022-08-25', //酒店入住日期
//        hotelPrice : '1470',  //酒店价格
//        orderStatus : '1' //0：已取消 1：待付款 2：已支付 3：已使用
//    },
//    {
//       hotelName :'苏州尼依格罗酒店', //酒店名称
//       hotelRoomName :'N1豪华大床房', //房间类型
//       personCount : '1', //住房人数
//       checkinDate :'2022-08-25', //酒店入住日期
//       hotelPrice : '1470',  //酒店价格
//       orderStatus : '0'
//   },
//   {
//    hotelName :'苏州尼依格罗酒店', //酒店名称
//    hotelRoomName :'N1豪华大床房', //房间类型
//    personCount : '1', //住房人数
//    checkinDate :'2022-08-25', //酒店入住日期
//    hotelPrice : '1470',  //酒店价格
//    orderStatus : '2'
// }
// ]
